
D   [0-9]
L   [a-zA-Z_]

%x fix_place
%x temp_late

%x config
%x list
%x pair
%x string
%x indent

%%

TMP\$                   { begin(StartCondition_::temp_late); }

<temp_late>             {
    YLY\$               { begin(StartCondition_::fix_place);}
    [\n]                { curIndent = 0; out() << "\n"; begin(StartCondition_::indent);}
    .                   { out() << matched();}
    \$TMP               { more(); begin(StartCondition_::INITIAL);}
}

<indent>                {
    [ ]                 { out() << " "; curIndent++; }
    [^ ]                { redo(1); begin(StartCondition_::temp_late);}
}

<fix_place>             {
    \$YLY               { out() << replacedFixStr(matched()); begin(StartCondition_::temp_late);}
    .                   { more();  }
}

CONFIG\$                { begin(StartCondition_::config); }
<config>                {
    \$CONFIG            { begin(StartCondition_::INITIAL);}
    {L}({L}|{D})*       { pair1 = matched(); begin(StartCondition_::pair); }
    [ \t]               { }
}
<pair>                  {
    \"                  { begin(StartCondition_::string); }
    [ \t]               { }
}

<string>                {
    \"                  { pair2 = matched(); pair2=pair2.substr(0, pair2.size() - 1); makeGlobalPairValue(); begin(StartCondition_::config); }
    [^"]                { more(); }
}




[cC][rR][eE][aA][tT][eE]                                              { return CREATE;}
[tT][aA][bB][lL][eE]                                                  { return TABLE;}
[pP][rR][iI][mM][aA][rR][yY]                                          { return PRIMARY;}
[kK][eE][yY]                                                          { return KEY; }
[tT][eE][xX][tT]                                                      { return TEXT; }
[iI][nN][tT][eE][gG][eE][rR]                                          { return INTEGER; }
[aA][uU][tT][oO][iI][nN][cC][rR][eE][mM][eE][nN][tT]                  {}

{L}({L}|{D})*                                                         { return ID; }
\n                                                                    { return NEWLINE;}
[ \t]                                                                 { }
'('                                                                   { return L_B;}
')'                                                                   { return R_B;}
,                                                                     {}
;
.                                                                     { std::cout << "RRROROR" << matched() << "ERRRROOR" << std::endl; }
